import request from '@/utils/request';
import { VerVO, VerForm, VerQuery } from '@/api/system/version/types';
import { AxiosPromise } from 'axios';

/**
 * app版本列表
 * @param query 
 * @returns 
 */
// export const listVersion = (query: VerQuery): AxiosPromise<{list: VerVO, total: number}> => {
export const listVersion = (query: VerQuery): AxiosPromise<TableInfoVO<VerVO>> => {
  return request({
    url: '/app/version/list',
    method: 'get',
    params: query
  });
};

/**
 * 添加app版本
 * @param data 
 * @returns 
 */
export const addVersion = (data: VerForm) => {
  return request({
    url: '/app/version',
    method: 'post',
    data: data
  });
};

/**
 * 修改app版本
 * @param data 
 * @returns 
 */
export const updateVersion = (data: VerForm) => {
  return request({
    url: '/app/version',
    method: 'put',
    data: data
  });
};

/**
 * 删除app版本
 * @param id 
 * @returns 
 */
export const delVersion = (id: string | number) => {
  return request({
    url: `/app/version/${id}`,
    method: 'delete'
  });
};

/**
 * app版本启用禁用
 * @param id 
 * @returns 
 */
export const enableVersion = (id: string | number) => {
  return request({
    url: `/app/version/enable/${id}`,
    method: 'put'
  });
};